package com.gl.controller;


import com.gl.entity.EduVideo;
import com.gl.service.EduVideoService;
import com.gl.utils.CommonResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * <p>
 * 课程视频 前端控制器
 * </p>
 *
 * @author testjava
 * @since 2020-12-14
 */
@RestController
@RequestMapping("/video")
public class EduVideoController {

    @Autowired
    private EduVideoService videoService;
    //根据阿里云视频id获取视频凭证
    @GetMapping("getALiYunAuth/{id}")
    public String getALiYunAuth(@PathVariable String id){
        String auth = videoService.getALiYunAuth(id);
        return auth;
    }


    //后台---------------------------------------------------------------
    //上传视频
    @PostMapping("uploadAlyVideo")
    public CommonResponse uploadAlyVideo(MultipartFile file){
        //返回上传视频id
        String videoId = videoService.uploadAlyVideo(file);
        return CommonResponse.ok().data("videoId",videoId);
    }

    //添加小节
    @PostMapping("saveVideo")
    public CommonResponse saveVideo(@RequestBody  EduVideo video){
        videoService.save(video);
        return CommonResponse.ok();
    }


}

